Skip to content

fix(c++): replace deprecated std::aligned_storage#3793

Merged
chaokunyang merged 3 commits into
apache:mainfrom
RisinT96:fix-deprecated-warning
Jun 29, 2026
Merged

fix(c++): replace deprecated std::aligned_storage#3793
chaokunyang merged 3 commits into
apache:mainfrom
RisinT96:fix-deprecated-warning

Conversation

@RisinT96

Copy link
Copy Markdown
Contributor

Why?

std::aligned_storage is marked as deprecated in C++23, as can be seen in the following compilation warning:

<project>/build/_deps/fory-src/cpp/fory/util/result.h:325:21: warning: ‘template<long unsigned int _Len, long unsigned int _Align> struct std::aligned_storage’ is deprecated [-Wdeprecated-declarations]
   325 |       typename std::aligned_storage<sizeof(E), alignof(E)>::type;
       |                     ^~~~~~~~~~~~~~~
 In file included from /usr/include/c++/13/bits/move.h:37,
                  from /usr/include/c++/13/bits/atomic_base.h:39,
                  from /usr/include/c++/13/atomic:41,
                  from <project source file>:
 /usr/include/c++/13/type_traits:2099:5: note: declared here
  2099 |     aligned_storage

What does this PR do?

Replaces std::aligned_storage with a std::byte array enclosed in an aligned struct.

  • std::byte is available since C++17 - the minimum supported version by fory.
  • alignas is available since C++11

This change shouldn't break anything.

AI Contribution Checklist

  • Substantial AI assistance was used in this PR: no

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

RisinT96 and others added 2 commits June 29, 2026 09:40
`std::aligned_storage` is marked as deprecated in c++23, replaced it with
an aligned `std::byte` array.

* `std::byte` is available since c++17 - the minimum supported version by
  fory.
* `alignas` is available since c++11
@RisinT96 RisinT96 force-pushed the fix-deprecated-warning branch from 408ce7e to cfd3227 Compare June 29, 2026 06:40
@chaokunyang chaokunyang merged commit f220885 into apache:main Jun 29, 2026
61 checks passed
@RisinT96 RisinT96 deleted the fix-deprecated-warning branch June 29, 2026 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants